using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace ImageUploaderComponent.Data{

    public interface IDataService : IDisposable {
        /// <summary>
        /// Starts a distributed transaction
        /// </summary>
        /// <returns>TransactionKey</returns>
        Guid BeginTransaction(string clientId, int userId, int skillKeyId);
        List<MediaData> GetImagesForSkill(int skillId);

        /// <summary>
        /// Starts the Asynch upload of a file. 
        /// </summary>
        /// <param name="imageData">A mediaData.  ImageBytes[] will be populated</param>
        /// <param name="updateProgress">Callback for progress</param>
        /// <param name="updateComplete">Callback for upload complete.  Probably send this after the file copy, so I know to complete the progress bar.</param>
        void BeginUploadFile(MediaData imageData,  Action<Guid, double> updateProgress, Action<Guid, ResultStruct> updateComplete);

        void DeleteFile(Guid itemKey);

        void ArchiveItem(Guid itemKey);

        
        /// <summary>
        /// Commits a transaction by writing the proper database entries for each item in the list
        /// </summary>
        /// <param name="transactionKey">The key for this transaction</param>
        /// <param name="imagesToCommit">A list of keys for images previously transmitted.  If the key exists, commit the image.
        ///         If not, write that fact to the result struct
        /// </param>
        /// <returns></returns>
        ResultStruct Commit(Guid transactionKey, List<Guid> imagesToCommit);
    
        /// <summary>
        /// Delete images previously transmitted, but not committed
        /// </summary>
        /// <param name="transactionKey"></param>
        /// <param name="imagesToRollback">A list if the images to delete.</param>
        /// <returns></returns>
        ResultStruct Rollback(Guid transactionKey, List<Guid> imagesToRollback);


        void Dispose();
    }
    

    /// <summary>
    /// To Be Defined.  What's in it is just what I am using now.  It can change
    /// </summary>
    public enum UploadStatus {
        ValidUploadAttempt, InvalidExtension,
        ImageTooSmall,
        Success,
        Started
    }
    public struct ResultStruct{
        public UploadStatus Status;

        public ResultStruct(UploadStatus success){
            Status = success;
        }
    }
}